package com.org.gameloft.GLIDER.util.diff;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Aug 7, 2007
 * Time: 12:17:53 PM
 * Revision: 0
 */
public class Test
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader in1 = new BufferedReader(new FileReader("diff1"));
        BufferedReader in2 = new BufferedReader(new FileReader("diff2"));

        String[] s1 = new String[1000];
        String[] s2 = new String[1000];
        String line;

        int p1 = 0, p2 = 0;
        while ((line = in1.readLine()) != null)
            s1[p1++] = line;
        while ((line = in2.readLine()) != null)
            s2[p2++] = line;

        DiffPoint[] p = new DiffPoint[2];
        p[0] = new DiffPoint(0,0);
        p[1] = new DiffPoint(p1,p2);


        Difference[] difs = new DiffImpl().diff(s1,s2,p);

        for (int i=0;i<difs.length;i++)
        {
            if (difs[i].getType() == Difference.EQUAL)
                System.out.println("= "+s1[difs[i].getLine1()]);
            if (difs[i].getType() == Difference.INSERT)
                System.out.println("> "+s2[difs[i].getLine2()]);
            if (difs[i].getType() == Difference.REMOVE)
                System.out.println("< "+s1[difs[i].getLine1()]);
        }

        
    }
}
